package com.company;


import java.io.IOException;
import java.util.Scanner;

/**
 * @author Administrator
 */

public class HJ22汽水瓶 {

    public static void main(String[] args) throws IOException {

        Scanner scanner = new Scanner(System.in);

        while (scanner.hasNext()) {
            int count = 0;
            int input = scanner.nextInt();
            if (input == 0) {
                break;
            }
            while (input != 0) {
                int temp = input / 3;
                count += temp;
                input = input % 3 + temp;
                if (input < 3) {
                    break;
                }
            }
            if (input == 2) {
                count++;
            }

            System.out.println(count);
        }
    }
}
